package com.hndfsj.minio.service;

import io.minio.MinioClient;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class MinioClientService {
    private static final Logger LOGGER = LoggerFactory.getLogger(MinioClient.class);
    private MinioClient minioClient = null;

    public MinioClientService() {
    }

    public MinioClient getClient(String endpoint, String accessKey, String secretKey) {
        try {
            if (this.minioClient == null) {
                this.minioClient =  MinioClient.builder().endpoint(endpoint).credentials(accessKey, secretKey).build();
            }

            return this.minioClient;
        } catch (Exception e) {
            LOGGER.error("error: {}", e.getMessage());
            return null;
        }
    }
}